<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <a href="https://www.jd.com">京东</a>
</body>
<script>
    // 页面相关的事件  onload onresize onscroll

    // onfocus   onblur   onbeforeunload  (了解)

    var count = 0;

    // onfocus 窗口聚焦  当从其他窗口/界面 切换到当前页面触发
    window.onfocus = function(){
        console.log("窗口聚焦",count);
    }

    // onblur  窗口失焦   从当前窗口切换到其他界面/窗口时触发
    window.onblur = function(){
        console.log("窗口失焦");
        count++;
    }

    // onbeforeunload    页面离开之前触发 (a标签跳转新页面 刷新  关闭浏览器窗口)
    window.onbeforeunload = function(){
        console.log("页面离开");
        return "11111";
    }



</script>
</html>